<?php

namespace app\api\controller\v1\store\base;

use app\admin\model\DataStoreUser;
use app\admin\model\DataStoreUserType;
use app\api\controller\Api;
use app\api\services\v1\store\StoreService;

class MoveIn extends Api
{

    private $services;
    public function initialize()
    {
        parent::initialize();
        $this->services = app()->make(StoreService::class);
    }





    public function set()
    {

        $rule = [
            'store_type'    => 'require',
            'store_name'    => 'require',
            'address'    => 'require',
            'tel'    => 'require',
            'consumption'    => 'require',
            'remarks'    => 'require',
            'lat'    => 'require',
            'lng'    => 'require',
        ];
        $message  =   [
            'store_type.require' => '商户类型不为空',
            'store_name.require' => '商户名称不为空',
            'address.require' => '所在地区不为空',
            'tel.require' => '电话不为空',
            'consumption.require' => '消费标准不为空',
            'remarks.require' => '简介不为空',
            'lat.require' => '纬度不为空',
            'lng.require' => '经度不为空',
        ];

        $this->validate($this->post, $rule,$message);
        $this->post['unid'] =$this->user['id'];
        if($this->services->in($this->post)){
            $this->success('申请成功，待审核');
        }else{
            $this->error('申请失败');
        }
    }



    public function get(){

        $save_store = DataStoreUser::where(['unid'=>$this->user['id']])->findOrEmpty();
        if($save_store->isEmpty())$this->error('商铺不存在');
        $save_store['status_text'] = $save_store->status_text;
        $this->success('获取成功',$save_store);


    }







}